<?php
/**
 * Created by PhpStorm.
 * User: leo
 * Date: 2018/5/22
 * Time: 0:35
 */
include '../classes/logincheck.php';
include "../classes/conn.php";
if(islogin()!='teacher_login'){
    die('error');
}

$class=$_POST['class'];
$stus=$_POST['stus'];
$fails=0;
for($i=0;$i<count($stus);$i++){
    $psw=md5(substr($stus[$i], -6));
    $query="update student set psw='{$psw}' where num='{$stus[$i]}' and class='{$class}'";
    $res=mysql_query($query);
    if(!$res){
        $fails++;
    }
}

if($fails){
    echo '0';
}
else echo '1';